//
//  YCActivitiesCell.m
//  YCSchool
//
//  Created by yanglinxia on 16/4/28.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCActivitiesCell.h"

@interface YCActivitiesCell ()
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIImageView *activitiesImageView;
@property (weak, nonatomic) IBOutlet UILabel *activitiesTitileLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentTextLabel;
@property (weak, nonatomic) IBOutlet UILabel *comefromWebsiteLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@end

@implementation YCActivitiesCell

- (void)awakeFromNib {
    self.bgView.layer.cornerRadius = 10;
    self.bgView.layer.masksToBounds = YES;
    
    self.activitiesTitileLabel.font = [UIFont systemFontOfSize:20];
    self.activitiesTitileLabel.textColor = [UIColor whiteColor];
    self.activitiesTitileLabel.numberOfLines = 0;
    
    self.activitiesImageView.image = [UIImage yc_placeHolderImageForSize:CGSizeMake(kScreenWidth - 28, 135)];
    
    self.contentTextLabel.font = [UIFont systemFontOfSize:14];
    self.contentTextLabel.numberOfLines = 0;
    self.contentTextLabel.textColor = [UIColor blackColor];
    
    self.comefromWebsiteLabel.font = [UIFont systemFontOfSize:9];
    self.comefromWebsiteLabel.textColor = [UIColor yc_colorWithUInt:0x1a1a1a];
    
    self.timeLabel.font = [UIFont systemFontOfSize:9];
    self.timeLabel.textColor = [UIColor yc_colorWithUInt:0x1a1a1a];
}

- (void)setItemModel:(YCActivitiesModel *)itemModel
{
    _itemModel = itemModel;
    
    // 设置标题
    self.activitiesTitileLabel.text = itemModel.title;
    
    // 设置内容
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    style.firstLineHeadIndent = 0;//首行缩进
    style.lineSpacing = 7;//行距
    style.alignment = NSTextAlignmentLeft;
    
    NSAttributedString * textValue = [[NSAttributedString alloc]initWithString:itemModel.des attributes:@{NSParagraphStyleAttributeName:style,
                        NSForegroundColorAttributeName:[UIColor yc_colorWithUInt:0x1a1a1a],
                        }];
    
    self.contentTextLabel.attributedText = textValue;
    
    // 设置来自哪
    self.comefromWebsiteLabel.text = itemModel.source;
    
    // 设置显示时间
    self.timeLabel.text = itemModel.addtime_str;
    // 设置图片
    [self.activitiesImageView yc_setWebImageWithURLString:[itemModel.img appendBaseUrl] holderSize:CGSizeMake(kScreenWidth - 28, 132)];

}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
